package com.tjy.farmer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.tjy.farmer.domain.FarmerCountInfo;
import com.tjy.farmer.service.IFarmerCountInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjy.common.annotation.Log;
import com.tjy.common.core.controller.BaseController;
import com.tjy.common.core.domain.AjaxResult;
import com.tjy.common.enums.BusinessType;
import com.tjy.farmer.domain.FarmerCountInfo;
import com.tjy.farmer.service.IFarmerCountInfoService;
import com.tjy.common.utils.poi.ExcelUtil;
import com.tjy.common.core.page.TableDataInfo;

/**
 * 数量统计Controller
 * 
 * @author tjy
 * @date 2025-09-08
 */
@RestController
@RequestMapping("/farmer/count")
public class FarmerCountInfoController extends BaseController
{
    @Autowired
    private IFarmerCountInfoService farmerCountInfoService;

    /**
     * 查询数量统计列表
     */
    @PreAuthorize("@ss.hasPermi('beearea:beearea:list')")
    @GetMapping("/list")
    public TableDataInfo list(FarmerCountInfo farmerCountInfo)
    {
        startPage();
        List<FarmerCountInfo> list = farmerCountInfoService.selectFarmerCountInfoList(farmerCountInfo);
        return getDataTable(list);
    }

    /**
     * 导出数量统计列表
     */
    @PreAuthorize("@ss.hasPermi('beearea:beearea:export')")
    @Log(title = "数量统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FarmerCountInfo farmerCountInfo)
    {
        List<FarmerCountInfo> list = farmerCountInfoService.selectFarmerCountInfoList(farmerCountInfo);
        ExcelUtil<FarmerCountInfo> util = new ExcelUtil<FarmerCountInfo>(FarmerCountInfo.class);
        util.exportExcel(response, list, "数量统计数据");
    }

    /**
     * 获取数量统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('beearea:beearea:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(farmerCountInfoService.selectFarmerCountInfoById(id));
    }

    /**
     * 新增数量统计
     */
    @PreAuthorize("@ss.hasPermi('beearea:beearea:add')")
    @Log(title = "数量统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FarmerCountInfo farmerCountInfo)
    {
        return toAjax(farmerCountInfoService.insertFarmerCountInfo(farmerCountInfo));
    }

    /**
     * 修改数量统计
     */
    @PreAuthorize("@ss.hasPermi('beearea:beearea:edit')")
    @Log(title = "数量统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FarmerCountInfo farmerCountInfo)
    {
        return toAjax(farmerCountInfoService.updateFarmerCountInfo(farmerCountInfo));
    }

    /**
     * 删除数量统计
     */
    @PreAuthorize("@ss.hasPermi('beearea:beearea:remove')")
    @Log(title = "数量统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(farmerCountInfoService.deleteFarmerCountInfoByIds(ids));
    }
}
